package com.jintian.smart.kernel.security.controller;

import com.jintian.smart.base.api.security.form.Level3ProtectConfigForm;
import com.jintian.smart.base.api.security.form.LoginFailQueryForm;
import com.jintian.smart.base.api.security.view.LoginFailVO;
import com.jintian.smart.kernel.core.constant.SwaggerTagConst;
import com.jintian.smart.kernel.core.domain.ResponseDTO;
import com.jintian.smart.kernel.core.domain.ValidateList;
import com.jintian.smart.kernel.core.system.IConfigService;
import com.jintian.smart.kernel.security.service.Level3ProtectConfigService;
import com.jintian.smart.kernel.security.service.SecurityLoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import com.jintian.smart.kernel.common.controller.SupportBaseController;
import com.jintian.smart.kernel.core.system.ConfigKeyEnum;
import org.beetl.sql.core.page.PageResult;
import org.springframework.web.bind.annotation.*;

/**
 * 网络安全
 */

@RestController
@Tag(name = SwaggerTagConst.Support.PROTECT)
@RequestMapping("/sec/protect")
public class ProtectController extends SupportBaseController {
    @Resource
    private SecurityLoginService securityLoginService;

    @Resource
    private Level3ProtectConfigService level3ProtectConfigService;

    @Resource
    private IConfigService configService;


    @Operation(summary = "分页查询大")
    @PostMapping("/loginFail/queryPage")
    public ResponseDTO<PageResult<LoginFailVO>> queryPage(@RequestBody @Valid LoginFailQueryForm queryForm) {
        return ResponseDTO.ok(securityLoginService.queryPage(queryForm));
    }


    @Operation(summary = "批量删除")
    @PostMapping("/loginFail/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return securityLoginService.batchDelete(idList);
    }

    @Operation(summary = "更新三级等保配置")
    @PostMapping("/level3protect/updateConfig")
    public ResponseDTO<String> updateConfig(@RequestBody @Valid Level3ProtectConfigForm configForm) {
        return level3ProtectConfigService.updateLevel3Config(configForm);
    }

    @Operation(summary = "查询 三级等保配置")
    @GetMapping("/level3protect/getConfig")
    public ResponseDTO<String> getConfig() {
        return ResponseDTO.ok(configService.getConfigValue(ConfigKeyEnum.LEVEL3_PROTECT_CONFIG));
    }
}
